const assert = require("assert");
const JsonKit = require("../src/json-kit.js");

describe("json.js", () => {
  const demo = `[{"a":[{"c":{"d":"1","e":2},"f":1},{"c2":{"d2":"1","e2":2},"f2":1}]}]`;
  describe("findFirstTree()", () => {
    it("ok", async () => {
      try {
        const result = await JsonKit.findFirstTree(JSON.parse(demo), "e", 2);
        console.log(JSON.stringify(result));
        assert(true);
      } catch (e) {
        console.log(e);
        assert(false);
      }
    });
  });

  describe("remove()", () => {
    it("ok", async () => {
      try {
        const result = await JsonKit.remove(JSON.parse(demo), ["e", "f"]);
        console.log(JSON.stringify(result));
        assert(true);
      } catch (e) {
        console.log(e);
        assert(false);
      }
    });
  });
});
